<?php
	mysql_connect("localhost", "root", "%Tg34fv1")or die("cannot connect"); 
	mysql_select_db("wordWaffle")or die("cannot select DB");
	//echo "still here";
	//verify it's my turn to choose
	$myKey = mysql_real_escape_string(stripslashes($_GET['sesskey']));
	$myLetter = mysql_real_escape_string(stripslashes($_GET['letter']));
	$result=mysql_query("SELECT * FROM lettersGuessed WHERE letter IS NULL ORDER BY turnNumber");
	if ($row = mysql_fetch_assoc($result))
	{
		$turnKey = $row['sesskey'];
		if ($turnKey != $myKey) //my turn
			return "It's not your turn to choose.";
		else
		{
			$thisTurn = $row['turnNumber'];
			$result = mysql_query("UPDATE lettersGuessed SET letter='$myLetter' WHERE turnNumber='$thisTurn'");
		}
	}
?>